package CCF认证.第36次.跳房子;

import java.io.BufferedInputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(new BufferedInputStream(System.in));
        int n = scanner.nextInt();
        int[] a = new int[n+1];
        int[] k = new int[n+1];

        for (int i = 1; i <= n; i++) {
            a[i] = scanner.nextInt();
        }
        for (int i = 1; i <= n; i++) {
            k[i] = scanner.nextInt();
        }

        // 贪心
        int count = 0, p = 1;
        while (p<n){
            // 当前位置最远
            int max = Math.min(p+k[p],n);
            if(max==n) {
                count++;
                break;
            }
            int max_next = -1; // 能跳到的最远位置
            int max_p = -1; // 能跳到的最远位置的下一次下标
            for (int i = p+1; i <= max; i++) {
                int t = i-a[i];
                if(t>max_next){
                    max_next = t;
                    max_p=i;
                }
            }
            if(p==max_p -a[max_p]){
                System.out.println(-1);
                return;
            }


            p = max_p -a[max_p];
            System.out.println(p);
            count++;
        }
        System.out.println(count);



    }
}
